{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { composeRef, supportRef } from \"rc-util/es/ref\";\nimport * as React from 'react';\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\nimport { observe, unobserve } from '../utils/observerUtil';\nimport DomWrapper from './DomWrapper';\nimport { CollectionContext } from '../Collection';\nexport default function SingleObserver(props) {\n  var children = props.children,\n    disabled = props.disabled;\n  var elementRef = React.useRef(null);\n  var wrapperRef = React.useRef(null);\n  var onCollectionResize = React.useContext(CollectionContext);\n  // =========================== Children ===========================\n  var isRenderProps = typeof children === 'function';\n  var mergedChildren = isRenderProps ? children(elementRef) : children;\n  // ============================= Size =============================\n  var sizeRef = React.useRef({\n    width: -1,\n    height: -1,\n    offsetWidth: -1,\n    offsetHeight: -1\n  });\n  // ============================= Ref ==============================\n  var canRef = !isRenderProps && /*#__PURE__*/React.isValidElement(mergedChildren) && supportRef(mergedChildren);\n  var originRef = canRef ? mergedChildren.ref : null;\n  var mergedRef = React.useMemo(function () {\n    return composeRef(originRef, elementRef);\n  }, [originRef, elementRef]);\n  // =========================== Observe ============================\n  var propsRef = React.useRef(props);\n  propsRef.current = props;\n  // Handler\n  var onInternalResize = React.useCallback(function (target) {\n    var _propsRef$current = propsRef.current,\n      onResize = _propsRef$current.onResize,\n      data = _propsRef$current.data;\n    var _target$getBoundingCl = target.getBoundingClientRect(),\n      width = _target$getBoundingCl.width,\n      height = _target$getBoundingCl.height;\n    var offsetWidth = target.offsetWidth,\n      offsetHeight = target.offsetHeight;\n    /**\n     * Resize observer trigger when content size changed.\n     * In most case we just care about element size,\n     * let's use `boundary` instead of `contentRect` here to avoid shaking.\n     */\n    var fixedWidth = Math.floor(width);\n    var fixedHeight = Math.floor(height);\n    if (sizeRef.current.width !== fixedWidth || sizeRef.current.height !== fixedHeight || sizeRef.current.offsetWidth !== offsetWidth || sizeRef.current.offsetHeight !== offsetHeight) {\n      var size = {\n        width: fixedWidth,\n        height: fixedHeight,\n        offsetWidth: offsetWidth,\n        offsetHeight: offsetHeight\n      };\n      sizeRef.current = size;\n      // IE is strange, right?\n      var mergedOffsetWidth = offsetWidth === Math.round(width) ? width : offsetWidth;\n      var mergedOffsetHeight = offsetHeight === Math.round(height) ? height : offsetHeight;\n      var sizeInfo = _objectSpread(_objectSpread({}, size), {}, {\n        offsetWidth: mergedOffsetWidth,\n        offsetHeight: mergedOffsetHeight\n      });\n      // Let collection know what happened\n      onCollectionResize === null || onCollectionResize === void 0 ? void 0 : onCollectionResize(sizeInfo, target, data);\n      if (onResize) {\n        // defer the callback but not defer to next frame\n        Promise.resolve().then(function () {\n          onResize(sizeInfo, target);\n        });\n      }\n    }\n  }, []);\n  // Dynamic observe\n  React.useEffect(function () {\n    var currentElement = findDOMNode(elementRef.current) || findDOMNode(wrapperRef.current);\n    if (currentElement && !disabled) {\n      observe(currentElement, onInternalResize);\n    }\n    return function () {\n      return unobserve(currentElement, onInternalResize);\n    };\n  }, [elementRef.current, disabled]);\n  // ============================ Render ============================\n  return /*#__PURE__*/React.createElement(DomWrapper, {\n    ref: wrapperRef\n  }, canRef ? /*#__PURE__*/React.cloneElement(mergedChildren, {\n    ref: mergedRef\n  }) : mergedChildren);\n}","map":{"version":3,"names":["_objectSpread","composeRef","supportRef","React","findDOMNode","observe","unobserve","DomWrapper","CollectionContext","SingleObserver","props","children","disabled","elementRef","useRef","wrapperRef","onCollectionResize","useContext","isRenderProps","mergedChildren","sizeRef","width","height","offsetWidth","offsetHeight","canRef","isValidElement","originRef","ref","mergedRef","useMemo","propsRef","current","onInternalResize","useCallback","target","_propsRef$current","onResize","data","_target$getBoundingCl","getBoundingClientRect","fixedWidth","Math","floor","fixedHeight","size","mergedOffsetWidth","round","mergedOffsetHeight","sizeInfo","Promise","resolve","then","useEffect","currentElement","createElement","cloneElement"],"sources":["/data/messenger.client/node_modules/rc-resize-observer/es/SingleObserver/index.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { composeRef, supportRef } from \"rc-util/es/ref\";\nimport * as React from 'react';\nimport findDOMNode from \"rc-util/es/Dom/findDOMNode\";\nimport { observe, unobserve } from '../utils/observerUtil';\nimport DomWrapper from './DomWrapper';\nimport { CollectionContext } from '../Collection';\nexport default function SingleObserver(props) {\n  var children = props.children,\n    disabled = props.disabled;\n  var elementRef = React.useRef(null);\n  var wrapperRef = React.useRef(null);\n  var onCollectionResize = React.useContext(CollectionContext);\n  // =========================== Children ===========================\n  var isRenderProps = typeof children === 'function';\n  var mergedChildren = isRenderProps ? children(elementRef) : children;\n  // ============================= Size =============================\n  var sizeRef = React.useRef({\n    width: -1,\n    height: -1,\n    offsetWidth: -1,\n    offsetHeight: -1\n  });\n  // ============================= Ref ==============================\n  var canRef = !isRenderProps && /*#__PURE__*/React.isValidElement(mergedChildren) && supportRef(mergedChildren);\n  var originRef = canRef ? mergedChildren.ref : null;\n  var mergedRef = React.useMemo(function () {\n    return composeRef(originRef, elementRef);\n  }, [originRef, elementRef]);\n  // =========================== Observe ============================\n  var propsRef = React.useRef(props);\n  propsRef.current = props;\n  // Handler\n  var onInternalResize = React.useCallback(function (target) {\n    var _propsRef$current = propsRef.current,\n      onResize = _propsRef$current.onResize,\n      data = _propsRef$current.data;\n    var _target$getBoundingCl = target.getBoundingClientRect(),\n      width = _target$getBoundingCl.width,\n      height = _target$getBoundingCl.height;\n    var offsetWidth = target.offsetWidth,\n      offsetHeight = target.offsetHeight;\n    /**\n     * Resize observer trigger when content size changed.\n     * In most case we just care about element size,\n     * let's use `boundary` instead of `contentRect` here to avoid shaking.\n     */\n    var fixedWidth = Math.floor(width);\n    var fixedHeight = Math.floor(height);\n    if (sizeRef.current.width !== fixedWidth || sizeRef.current.height !== fixedHeight || sizeRef.current.offsetWidth !== offsetWidth || sizeRef.current.offsetHeight !== offsetHeight) {\n      var size = {\n        width: fixedWidth,\n        height: fixedHeight,\n        offsetWidth: offsetWidth,\n        offsetHeight: offsetHeight\n      };\n      sizeRef.current = size;\n      // IE is strange, right?\n      var mergedOffsetWidth = offsetWidth === Math.round(width) ? width : offsetWidth;\n      var mergedOffsetHeight = offsetHeight === Math.round(height) ? height : offsetHeight;\n      var sizeInfo = _objectSpread(_objectSpread({}, size), {}, {\n        offsetWidth: mergedOffsetWidth,\n        offsetHeight: mergedOffsetHeight\n      });\n      // Let collection know what happened\n      onCollectionResize === null || onCollectionResize === void 0 ? void 0 : onCollectionResize(sizeInfo, target, data);\n      if (onResize) {\n        // defer the callback but not defer to next frame\n        Promise.resolve().then(function () {\n          onResize(sizeInfo, target);\n        });\n      }\n    }\n  }, []);\n  // Dynamic observe\n  React.useEffect(function () {\n    var currentElement = findDOMNode(elementRef.current) || findDOMNode(wrapperRef.current);\n    if (currentElement && !disabled) {\n      observe(currentElement, onInternalResize);\n    }\n    return function () {\n      return unobserve(currentElement, onInternalResize);\n    };\n  }, [elementRef.current, disabled]);\n  // ============================ Render ============================\n  return /*#__PURE__*/React.createElement(DomWrapper, {\n    ref: wrapperRef\n  }, canRef ? /*#__PURE__*/React.cloneElement(mergedChildren, {\n    ref: mergedRef\n  }) : mergedChildren);\n}"],"mappings":"AAAA,OAAOA,aAAa,MAAM,0CAA0C;AACpE,SAASC,UAAU,EAAEC,UAAU,QAAQ,gBAAgB;AACvD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,WAAW,MAAM,4BAA4B;AACpD,SAASC,OAAO,EAAEC,SAAS,QAAQ,uBAAuB;AAC1D,OAAOC,UAAU,MAAM,cAAc;AACrC,SAASC,iBAAiB,QAAQ,eAAe;AACjD,eAAe,SAASC,cAAc,CAACC,KAAK,EAAE;EAC5C,IAAIC,QAAQ,GAAGD,KAAK,CAACC,QAAQ;IAC3BC,QAAQ,GAAGF,KAAK,CAACE,QAAQ;EAC3B,IAAIC,UAAU,GAAGV,KAAK,CAACW,MAAM,CAAC,IAAI,CAAC;EACnC,IAAIC,UAAU,GAAGZ,KAAK,CAACW,MAAM,CAAC,IAAI,CAAC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